<?php
/**
 * Created by PhpStorm.
 * User: Office
 * Date: 2017/12/18
 * Time: 15:07
 */

header("Content-type: text/html; charset=utf-8");
/*//auth
$AUTH = array();
$AUTH['user']='admin';
$AUTH['pwd']=md5("admin");*/

//login
/*session_start();
if(isset($_POST['user'])&&isset($_POST['pwd'])){
    $user=$_POST['user'];
    $pwd = md5($_POST['pwd']);
    if($user !== $AUTH['user'] || $pwd !== $AUTH['pwd']){
        echo "<strong style='color: red'>用户名或密码错误！</strong>";
    }else{
        $_SESSION['user']= $user;
        header("location:blog_in.html");
    }
}*/


session_start();
//链接数据库
$link = mysqli_connect('localhost', 'root', 'root', "login0");

//获取页面表单
$fuser=$_POST["user"];
$fpwd=$_POST["pwd"];

if ($link) {
    mysqli_query($link, "set names utf8");
    $pwdL = md5($fpwd);
    $sql2 = "select * from user where username='{$fuser}'and  pwd='{$pwdL}'";
    $re=mysqli_query($link, $sql2);
    $data = mysqli_fetch_assoc($re);

    if($data){
        $_SESSION['user']= $fuser;
        header("location:blog_in.php");
    }else{
        echo "<strong style='color: red'>用户名或者密码不正确！</strong>";
    }
}

?>